import State from './State'
import { StateMachine } from './StateMachine'

/**
 * 子状态机基类
 * 特点：参数跟父状态机共享
 */
export abstract class SubStateMachine  {
  private _currentState: State | null = null
  stateMachines: Map<string, State> = new Map()

  constructor(public fsm: StateMachine) {
  }

  get currentState() {
    return this._currentState
  }

  set currentState(newState: State) {
    this._currentState = newState
    this._currentState.run()
  }

  abstract run(): void

}
